import React from 'react';

export default class LabelList extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            data : this.props.data
        }
        this.renderItems = this.renderItems.bind(this)
    }
    renderItems(data){
        let _items = [];
        let _c = 0;
        ((d,a)=>{
            for(let i of  d){
                a.push(
                    <li key={i+(_c++)}><label>{i.label}</label>{i.value}</li>
                )
            }
        })(data,_items);
        return _items
    }
    render(){
        return (
            <div className="label-list">
                {this.props.title?<h2>{this.props.title}</h2>:''}
                <ul>{this.renderItems(this.props.data)}</ul>
            </div>
        )
    }
}